$(document).ready(function() {
$("#slidepromociones").owlCarousel({
lazyLoad : true,
animateOut: 'fadeOut',
animateIn: 'fadeIn',
navigation : true, // Show next and prev buttons
slideSpeed : 300,
paginationSpeed : 400,
dots: false,
nav: true,
controls: true,
items : 1,
itemsMobile : true,
loop:true,
autoplay: true,
autoplayTimeout: 3000,
autoplayHoverPause: true,
navText: ["", ""]
});
$("#slidedestacados").owlCarousel({
lazyLoad : true,
animateOut: 'fadeOut',
animateIn: 'fadeIn',
navigation : true, // Show next and prev buttons
slideSpeed : 300,
paginationSpeed : 400,
nav: true,
controls: true,
items : 1,
itemsMobile : true,
loop:true,
autoplay: true,
autoplayTimeout: 5000,
autoplayHoverPause: true,
navText: ["", ""]
});
$("#f-llamame-home .llamame-send").click(function(e){
var telefono1 = $("#f-llamame-home .telefono").val();
if(telefono1){
bloqueoLlamame(1);
}else{
e.preventDefault();
alert('Favor de llenar tu teléfono');
return false;
}
//var gg = grecaptcha.getresponse();
/*var token = window.grecaptcha.getResponse(recaptchaId);
// if no token, mean user is not validated yet
if (!token) {
window.grecaptcha.execute(recaptchaId);
return;
}*/
});
$("#f-llamame-home").submit(function(e){
e.preventDefault();
return false;
});
var s=document.createElement('script');
s.src='js/interior-paquetes4.js';
document.body.appendChild(s);
bloqueoLlamame(0);
});
function bloqueoLlamame(balert){
var cont1 = 0;
cont1 = (getCookie('llamame') *1) + 1;
setCookie('llamame', cont1, 30);
//console.log('llamame-'+ cont1);
if(cont1 >= 4){
$("#f-llamame-home .llamame-send").prop('disabled', true).attr('title', 'Demasiados intentos, vuelva a intentar en 30 minutos.');
if(balert)
alert('Demasiados intentos, vuelva a intentar en 30 minutos.');
}
}
// funciones de cookies
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 60 * 1000)); //* 60
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
/*
window.onScriptLoad = function () {
// this callback will be called by recaptcah/api.js once its loaded. If we used
// render=explicit as param in script src, then we can explicitly render reCaptcha at this point
// element to "render" invisible captcha in
var htmlEl = document.querySelector('.recaptcha-holder');
// option to captcha
var captchaOptions = {
sitekey: '6LeMXVYUAAAAABc5l50d1Myb7kHU5vPs91_9TQS1',
size: 'invisible',
// reference to an actual function
callback: window.onUserVerified
};
// Only for "invisible" type. if true, will read value from html-element's data-* attribute if its not passed via captchaOptions
var inheritFromDataAttr = true;
// now render
recaptchaId = window.grecaptcha.render(htmlEl, captchaOptions, inheritFromDataAttr);
};
window.onUserVerified = function (token){
if ($('#P2_dato1').val()!="" ){ //&& $('#P2_dato2').val()!=""
//console.log( $("#f-llamame-home").serialize() );
$("#f-llamame-home .llamame-send").prop("disabled", true).addClass('disabled');
$.ajax({
type: 'POST',
url: 'sections/functions/quiero-contratar2.php',
data: $("#f-llamame-home").serialize(),
async: false, //blocks window close
success:function(msj){
//console.log(msj);
if ( msj == 'success' ){
$("#P2_telefono").val( $("#P2_dato1").val() );
//$("#P2_email").val( $("#P2_dato2").val() );
//console.log( $("#f-llamame-home1").serialize() );
$("#f-llamame-home1").submit();
$("#P2_dato1, #P2_dato2").val('');
//$("#f-llamame-home .llamame-send").remove();
}else{
alert(msj);
$("#f-llamame-home .llamame-send").prop("disabled", false).removeClass('disabled');
}
},
//si se pierden los datos presentamos error de ejecucion.
error:function(e1,e2,e3){
console.log(e1);
console.log(e2);
console.log(e3);
alert('Ha ocurrido un error durante la ejecución.');
$("#f-llamame-home .llamame-send").prop("disabled", false).removeClass('disabled');
}
});
}
}
*/